<template>
    <div class="pie-tools">
        <div class="topTools" :class="topClass" v-if="topTools">
            <p
                class="img-wrap"
                @click="changetopSelect(index, item.title)"
                v-for="(item, index) in topTools"
                :key="index"
            >
                <img
                    v-if="selecttopIndex === index"
                    :src="item.selectUrl"
                    :title="item.title"
                />
                <img v-else :src="item.url" :title="item.title" />
            </p>
        </div>
        <div class="img-list" v-if="toolList">
            <p
                class="img-wrap"
                @click="changeSelect(index, item.title)"
                :style="{
                    borderBottom:
                        index === toolList.length - 1
                            ? 0
                            : '1px solid rgba(255, 255, 255, 0.4) ',
                }"
                v-for="(item, index) in toolList"
                :key="index"
            >
                <img
                    v-if="selectIndex === index"
                    :src="item.selectUrl"
                    :title="item.title"
                />
                <img v-else :src="item.url" :title="item.title" />
            </p>
        </div>
    </div>
</template>

<script>
export default {
    name: "tools",
    props: ["toolList", "topTools", "topClass"],
    data() {
        return {
            selecttopIndex: -1,
            selectIndex: 10,
        };
    },

    mounted() {},

    methods: {
        changetopSelect(val, type) {
            this.selecttopIndex = val;
            this.$emit("showTools", type);
        },
        changeSelect(val, type) {
            this.selectIndex = val;
            this.$emit("showTools", type);
        },
    },
};
</script>

<style lang="scss" scoped>
.pie-tools {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 50;
    width: 38px;
    height: 100%;
    .topTools {
        position: absolute;
        top: 16px;
        right: 20px;
        z-index: 99;
    }
    .topImage {
        display: flex;
    }
    .occupyTopImage{
        display: flex;
        right: 400px;
        top: 0px;
    }
    .img-wrap {
        display: inline-block;
        width: 36px;
        height: 44px;
        background: linear-gradient(
            180deg,
            rgba(0, 43, 108, 0.8) 0%,
            rgba(0, 34, 104, 0.8) 100%
        );
        border: 1px solid #2c608c;
        padding: 0;
        box-sizing: border-box;
        line-height: 52px;
        text-align: center;
        cursor: pointer;
    }
    .top-img {
        width: 36px;
        height: 36px;
        line-height: 46px;
        background: linear-gradient(
            180deg,
            rgba(0, 43, 108, 0.8) 0%,
            rgba(0, 34, 104, 0.8) 100%
        );
        border: 1px solid #2c608c;
        cursor: pointer;
    }

    .img-list {
        position: absolute;
        bottom: 65px;
        // right: -10px;
        margin-bottom: 12px;
    }

    .reduction {
        cursor: pointer;
    }
}
</style>